/**
 * @description 基线项目入口文件
 */
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import {Router ,Route, IndexRoute, hashHistory, IndexRedirect} from 'react-router';
import {QMFetch,QMConst} from 'qm-ux';
import QMRoute from 'QMRoute'
QMFetch.register(401,()=>{
    window.location.href=QMConst.HOST["v_sso_server"]+"/logout";
})

import '../style/index.less';
ReactDOM.render((
    <QMRoute history={hashHistory}>
        <Route>
            <IndexRoute getComponent={async (nextState, cb) => {
                const Xsite = await import('./x-site/landing-page');
                cb(null, Xsite.default)
            }}/>
            <Route path="/articles" getComponent={async (nextState, cb) => {
                const Articles  = await import('./article/list');
                cb(null, Articles.default)
            }}/>
            <Route path="/article-section" getComponent={async (nextState, cb) => {
                const ArticleSection  = await import('./article/sections');
                cb(null, ArticleSection.default)
            }}/>
            <Route path="/goods-sort" getComponent={async (nextState, cb) => {
                const GoodsSort = await import('./goods/sort');
                cb(null, GoodsSort.default)
            }}/>

            {/*设置模块*/}
            <Route path="/setting/integral" getComponent={async (nextState, cb) => {
                const Integral = await import('./setting/integral');
                cb(null, Integral.default)
            }}/>
            <Route path="/setting/goods" getComponent={async (nextState, cb) => {
                const GoodSet = await import('./setting/good-set');
                cb(null, GoodSet.default)
            }}/>
            <Route path="/setting/order" getComponent={async (nextState, cb) => {
                const OrderSet = await import('./setting/order-set');
                cb(null, OrderSet.default)
            }}/>
            <Route path="/setting/register-login" getComponent={async (nextState, cb) => {
                const RegisterLogin = await import('./setting/register-login');
                cb(null, RegisterLogin.default)
            }}/>
            <Route path="/setting/refund" getComponent={async (nextState, cb) => {
                const Refund = await import('./setting/refund');
                cb(null, Refund.default)
            }}/>
            {/*订单列表*/}
            <Route path="/order/list(/:type)" getComponent={async (nextState, cb) => {
                const List = await import('./order/list');
                cb(null, List.default)
            }}/>
            <Route path="/order/start(/:tid)" getComponent={async (nextState, cb) => {
                const Valet = await import('./order/valet-order');
                cb(null, Valet.default)
            }}/>
            <Route path="/order/comment" getComponent={async (nextState, cb) => {
                const Comment = await import('./order/comment');
                cb(null, Comment.default)
            }} />
            {/*放在下面, 否则会拦截到其他的请求, 比如/order/comment*/}
            <Route path="/order/detail/:type/:tid" getComponent={async (nextState, cb) => {
                const Detail = await import('./order/detail');
                cb(null, Detail.default)
            }}/>
            <Route path="/order/edit/:type/:tid" getComponent={async (nextState, cb) => {
                const EditPrice = await import('./order/edit');
                cb(null, EditPrice.default)
            }}/>
             <Route path="/after/sales/auditing/:rid" getComponent={async (nextState, cb) => {
                 //订单及客服=》售后申请=》售后单详情，
                const OrderDetail = await import('./after-sales/order-detail');
                cb(null, OrderDetail.default)
            }}/>
            <Route path="/after/sales/audited/:rid" getComponent={async (nextState, cb) => {
                 //订单及客服=》退货单=》售后单详情，
                const OrderDetail = await import('./after-sales/order-detail');
                cb(null, OrderDetail.default)
            }}/>
            <Route path="/after/sales/waitrefund/:rid" getComponent={async (nextState, cb) => {
                 //会计=》退货单=》售后单详情
                const OrderDetailWaitRefund = await import('./after-sales/order-detail');
                cb(null, OrderDetailWaitRefund.default)
            }}/>
            <Route path="/after/sales/:tid" getComponent={async (nextState, cb) => {
                const Detail = await import('./after-sales/refund-orders');
                cb(null, Detail.default)
            }}/>
            <Route path="/after/sales/list/:type" getComponent={async (nextState, cb) => {
                //售后单列表
                const Detail = await import('./after-sales/list');
                cb(null, Detail.default)
            }}/>
           
            <Route path="/x-site/landing-page" getComponent={async (nextState, cb) => {
                const Xsite = await import('./x-site/landing-page');
                cb(null, Xsite.default)
            }}/>
            <Route path="/x-site/page-manage" getComponent={async (nextState, cb) => {
                const Xsite = await import('./x-site/page-manage');
                cb(null, Xsite.default)
            }}/>
            <Route path="/x-site/template-manage" getComponent={async (nextState, cb) => {
                const Xsite = await import('./x-site/template-manage');
                cb(null, Xsite.default)
            }}/>
            <Route path="/order/receipt" getComponent={async (nextState, cb) => {
                const Receipt = await import('./order/receipt');
                cb(null, Receipt.default)
            }}/>
            <Route path="/order/receipt/:tid" getComponent={async (nextState, cb) => {
                const ReceiptDetail = await import('./order/receipt-detail');
                cb(null, ReceiptDetail.default)
            }}/>

        </Route>
    </QMRoute>
),document.getElementById("react-content"));
